package com.zdp.provider.Command;

import com.netflix.hystrix.HystrixCommandGroupKey;
import com.netflix.hystrix.HystrixObservableCommand;
import rx.Observable;

/**
 * 类描述:
 *
 * @author ZhhengDP
 * @since 2021/8/20
 */
public class FallBackFailure2 extends HystrixObservableCommand<String> {

    public FallBackFailure2(){
        super(Setter.withGroupKey(HystrixCommandGroupKey.
                Factory.asKey("exampleGroup")));
    }

    /**
     * 具体的业务逻辑
     * @return
     */
    @Override
    protected Observable<String> construct() {
        System.out.println("业务逻辑执行");
        int i = 1/0;
        System.out.println("业务逻辑执行完毕");
        return Observable.just("成功");
    }

    /**
     * 服务降级逻辑
     * @return
     */
    @Override
    protected Observable<String> resumeWithFallback() {
        System.out.println("进入服务降级逻辑");
        return Observable.just("失败");
    }
}
